authApp.controller("loginController",function($scope,$http,$cookieStore,$cookies){
	$scope.isM=true;
	$scope.cancellogin=function(){
		var random=Math.random();
		location.href=paths.projectHome+"?random="+random;
	}
	$scope.login=function(){
		if($scope.eType==undefined){
			alert("请先选择专业");
			return
		}
		if($scope.eType=="2"&&$scope.sType==undefined){
			alert("请先选择科目");
			return
		}
		if($scope.user!=""&&$scope.password!=""){
			$http({
				method:'post',
				url:apis.schoolLogin,
				data:{'account':$scope.user,'password':$scope.password,'major':$scope.eType,'status':$scope.sType}
			}).success(function(response){
				var radom=Math.random();
				if(response.code=="000000"){
					$cookies.put('account',$scope.user,{"path":"/"});
					$cookies.put('accounttype','school',{"path":"/"});
					$cookies.put('major',$scope.eType,{"path":"/"});
					$cookies.put('employerName',response.data.schoolName,{"path":"/"});
					if($scope.eType=="2"){
						$cookies.put('majorType',$scope.sType,{"path":"/"});
					}else{
						$cookies.put('majorType',"0",{"path":"/"});
					}
					$cookies.put('schoolPid',response.data.pid,{"path":"/"});
					location.href=paths.schoolHome+"?radom="+radom;
				}else{
					alert(response.errorMsg);
				}
			}).error(function(){
				alert("服务器打瞌睡了，请稍等！");
			})
		}
	}
	$scope.toggleS=function(){
		if($scope.eType=="2"){
			$scope.isM=false;
		}else{
			$scope.isM=true;
		}
	}
})